#include <fstream>
#include <iostream>
#include "geometry.h"
#include <string>

int main()
{
	int n, m;
	std::vector<point> answ;

	std::cin >> n;
	point * points = new point [n];

	for(int i = 0; i < n; i++)
		std::cin >> points[i].x >> points[i].y;

	std::cin >> m;
	rectangle rct;

	for (int i = 0; i < m; i++)
	{
		std::cin >> rct.ld.x >> rct.ld.y;
		std::cin >> rct.ru.x >> rct.ru.y;
		answ.clear();
		for (int j = 0; j < n; j++) 
		{
			if (in_rectangle(rct, points[j]))
				answ.push_back(points[j]);
		}
		std::cout << answ.size() << "\n";
		for (size_t j = 0; j < answ.size(); j++)
		{
			std::cout << answ[j].x << " " << answ[j].y << "\n";
		}
	}

	return 0;
}